package com.kmvc.message.activity;

import com.kmvc.message.service.MessageService;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.util.Log;

public class BootCompleteReceicer extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {

		if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
			Log.e("kmvc", "开机广播");
			Intent ins = new Intent(context, MessageService.class);
			ins.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startService(ins);
		}

		if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
			Log.e("kmvc", "网络开关广播");
			Intent ins = new Intent(context, MessageService.class);
			ins.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);		
			context.startService(ins);
		}
		if (intent.getAction().equals(Intent.ACTION_REBOOT)) {
			Log.e("kmvc", "重启广播");
			Intent ins = new Intent(context, MessageService.class);
			ins.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);			
			context.startService(ins);
		}
	}
}
